<script type="text/javascript">
function editPhoto(obj, isShow){
	if(isShow){
		$('headerBox_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>').hide();
		$('boxEdit_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>').show();
		if($('aEdit_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>')) $('aEdit_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>').addClass('disableEdit');
	}else{
		$('headerBox_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>').show();
		$('boxEdit_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>').hide();
		if($('aEdit_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>')) $('aEdit_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>').removeClass('disableEdit');
	}
}
function submitFormEdit(){
   $$('.tag_div').destroy();
   $$('.tag_label').destroy();
   var form_values  = $('frmEditPhoto_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>').toQueryString();
          form_values += '&format=json';
         en4.core.request.send(new Request.JSON({
             url : en4.core.baseUrl + 'fphoto/photoe/quick-edit',
             data : form_values,
             onComplete: function(response) {
            	 boxNextPhotoFPhotoG('<?php echo $this->subject()->getHref()?>');
             }
         }), {
             //'element' : $('informations_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>')
        }); 
}
en4.core.runonce.add(function() {

	  var descEls = $$('.albums_viewmedia_info_caption');
	    if( descEls.length > 0 ) {
	      descEls[0].enableLinks();
	    }

	   taggerInstance = new Tagger('media_photo_next', {
      'title' : '<?php echo $this->translate('ADD TAG');?>',
      'description' : '<?php echo $this->translate('Type a tag or select a name from the list.');?>',
      'createRequestOptions' : {
        'url' : '<?php echo $this->url(array('module' => 'core', 'controller' => 'tag', 'action' => 'add'), 'default', true) ?>',
        'data' : {
          'subject' : '<?php echo $this->subject()->getGuid() ?>'
        }
      },
      'deleteRequestOptions' : {
        'url' : '<?php echo $this->url(array('module' => 'core', 'controller' => 'tag', 'action' => 'remove'), 'default', true) ?>',
        'data' : {
          'subject' : '<?php echo $this->subject()->getGuid() ?>'
        }
      },
      'cropOptions' : {
        'container' : $('media_photo_next')
      },
      'tagListElement' : 'media_tags',
      'existingTags' : <?php echo $this->action('retrieve', 'tag', 'core', array('sendNow' => false)) ?>,
      'suggestProto' : 'request.json',
      'suggestParam' : '<?php echo $this->url(array('module' => 'user', 'controller' => 'friends', 'action' => 'suggest', 'includeSelf' => true), 'default', true) ?>',
      'guid' : <?php echo ( $this->viewer()->getIdentity() ? "'".$this->viewer()->getGuid()."'" : 'false' ) ?>,
      'enableCreate' : <?php echo ( $this->canEdit ? 'true' : 'false') ?>,
      'enableDelete' : <?php echo ( $this->canEdit ? 'true' : 'false') ?>
    });
		//over function onMove
			
	    // Remove the href attrib while tagging
	    var nextHref = $('media_photo_next').get('class');
	    taggerInstance.addEvents({
	      'onBegin' : function() {
	    	  en4.fphoto.isOtherClick =  true;
//	    	  $('innerLeftCol').setStyle('line-height', 'normal');
	    	  $('innerLeftCol').scrollTo(0,0);
			  if($('boxBottomUnderImage')) $('boxBottomUnderImage').hide();
				if($$('.imageActionSwitch')) $$('.imageActionSwitch').setStyle('opacity', 0);
	      },
	      'onEnd' : function() {
//	    	  $('innerLeftCol').setStyle('line-height', ($('heightTable').get('class')/13.4).toString()+'em');
		   	  setTimeout("en4.fphoto.isOtherClick =  false", 1000);
	      }
	    });

	  
	 if($('frmEditPhoto_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>')) $('frmEditPhoto_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>').addEvent('submit', function(e){
			e.stop();
			$$('.tag_div').destroy();
			$$('.tag_label').destroy();
			var form_values  = $('frmEditPhoto_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>').toQueryString();
	        	form_values += '&format=json';
	        en4.core.request.send(new Request.JSON({
        	    url : en4.core.baseUrl + 'fphoto/photo/quick-edit',
        	    data : form_values
        	}), {
        	   	'element' : $('informations_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>')
        });	
	 });
	 //$('aEdit_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>').removeClass('disableEdit');
	 $('titlePhotoValue_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>').addEvents({
		'focus': function(){
			if (this.value.contains('<?php echo $this->translate('Write a title...')?>')) this.value = '';
		},
		'blur': function(){
			if (this.value == '') this.value = '<?php echo $this->translate('Write a title...')?>';
		}
	 });
	 $('desPhotoValue_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>').addEvents({
			'focus': function(){
				if (this.value.contains('<?php echo $this->translate('Write a description...')?>')) this.value = '';
			},
			'blur': function(){
				if (this.value == '') this.value = '<?php echo $this->translate('Write a description...')?>';
			}
	});

});
</script>
<div class="informations" id="informations_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>">
			<div id="headerBox_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>" style="display: block;">
				<div class="boxInfoUser">
					<div class="boxiconUser">
				        <?php echo $this->htmlLink($this->album->getOwner()->getHref(),$this->itemPhoto($this->album->getOwner(), 'thumb.icon')); ?>
					</div>
					<div class="boxInfoPhoto">
						<div class="boxUserLink"><?php echo $this->album->getOwner()->__toString()?></div>
						<div class="boxTimestamp"><?php echo $this->timestamp($this->photo->modified_date)?></div>
					</div>
					
					<?php if($this->photo->getTitle()):?>
					<div class="albums_viewmedia_info_title"><?php echo $this->photo->getTitle()?></div>
					<?php endif;?>
						
						<?php $isWith = false; if( $this->photo->getDescription() ): $isWith = true;?>		       
					   <span>
						<?php echo nl2br($this->photo->getDescription()) ?>
					   </span>
					<?php else: $isWith = false;?>
					 <?php if( $this->canEdit ): ?>
						<div>				    	
							<a href="javascript: void(0);" onclick="editPhoto(this, true);$('desPhotoValue_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>').focus();"><?php echo $this->translate('Add a description');?></a>
						</div>
						
					<?php endif;?>
					<?php endif; ?>
					<span class="albums_viewmedia_info_tags" id="media_tags" style="display: none;">
						<?php echo ($isWith)?'&nbsp;&ndash;&nbsp;'. $this->translate('with ') : $this->translate('With ');?>
					</span>
					
				</div>
				
				<!--<div style="clear: both;"></div>-->
				<!--<br>-->
				

	    	</div>
	    	<?php if($this->canEdit):?>
	    	<form id="frmEditPhoto_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>" name="frmEditPhoto" method="post" enctype="application/x-www-form-urlencoded">
		    	<div id="boxEdit_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>" class="boxEdit" style="display: none;">
		    		<div class="photoTitle gen">
		    			<input class="titlePhotoValue" id="titlePhotoValue_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>" class="textInput" type="text" name="title" value="<?php echo ($this->photo->getTitle())? $this->photo->getTitle() : $this->translate('Write a title...');?>">
		    		</div>
		    		<div class="photoDes gen">
		    			<textarea id="desPhotoValue_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>" name="description" id="photoDesArea_<?php echo $this->subject()->getType()?>_<?php echo $this->subject()->getIdentity()?>" class="areaDes"><?php echo ($this->photo->getDescription()) ? $this->photo->getDescription() : $this->translate('Write a description...')?></textarea>
		    		</div>
		    		<input type="hidden" value="<?php echo $this->photo->group_id?>" name="group_id">
		    		<input type="hidden" value="<?php echo $this->photo->getIdentity()?>" name="photo_id">
					<div class="editActions">     
                    
                    <a href="javascript:void(o);" onclick="submitFormEdit();"><?php echo $this->translate('Save changes');?></a>
                    or <a href="javascript:void(o);" onclick="editPhoto(this, false);"><?php echo $this->translate('Cancel');?></a>
					</div>		    	
		    	</div>
		    </form>
	    	<?php endif;?>
	    </div>